<template>
    <div>
        <!-- plain text only -->
        <v-text-region v-if="text && !ui" v-bind="$attrs" ></v-text-region>
        <!-- select elements mode -->
        <v-select-group v-if="!text && !ui" v-bind="$attrs" v-on="$listeners"></v-select-group>
        <!-- selector mode -->
        <v-tab-selector v-if="ui && !column && !cityPicker" v-bind="$attrs" v-on="$listeners">
            <slot></slot>
        </v-tab-selector>
        <!-- column group mode -->
        <v-column-group v-if="ui && column && !cityPicker" v-bind="$attrs" v-on="$listeners">
            <slot></slot>
        </v-column-group>
        <!-- city picker -->
        <v-city-picker v-if="ui && !column && cityPicker" v-bind="$attrs" v-on="$listeners">
            <slot></slot>
        </v-city-picker>
    </div>
</template>

<script>
    import selectGroup from './SelectGroup';
    import tabSelector from './TabSelector';
    import columnGroup from './ColumnGroup';
    import textRegion from './TextRegion';
    import cityPicker from './CityPicker';
    export default {
        name: "v-region",
        components: {
            'v-select-group': selectGroup,
            'v-text-region': textRegion,
            'v-tab-selector': tabSelector,
            'v-column-group': columnGroup,
            'v-city-picker': cityPicker
        },
        props:{
            ui: {
                type: Boolean,
                default: false
            },
            column: {
                type: Boolean,
                default: false
            },
            text: {
                type: Boolean,
                default: false
            },
            cityPicker: {
                type: Boolean,
                default: false
            }
        },
        mounted(){
            this.className = this.$el.className;
            this.$el.className = 'v-region';
        }
    }
</script>

<style lang="scss">
    $darkBg: #F5F5F5;
    div.v-region {
        display: inline-block;
        select {
            width: auto;
            display: inline-block;
            overflow: hidden;
            box-sizing: content-box;
            padding: 0 12px;
            margin-right: 5px;
        }
    }
    div.rg-caller-container{ display: inline-block; }

    .rg-default-btn {
        display: inline-block;
        position: relative;
        padding: 6px 12px;
        background-color: white;
        border: 1px solid #cccccc;
        border-radius: 4px;
        font-size: 14px;
        line-height: 1.42857143;
        outline: 0 !important;
        color: #666666;
        transition: color .15s ease-in-out,
        background-color .15s ease-in-out,
        border-color .15s ease-in-out,
        box-shadow .15s ease-in-out;
        span.rg-caret-down { transition:transform .2s ease; }
        span.rg-clear-btn {
            margin-left: 5px;
            &:hover { font-weight: bold; }
        }
        &.rg-opened {
            box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
            border: 1px solid #aaa;
            color: black;
            background-color: #e0e0e0;
            span.rg-caret-down { transform: rotate(180deg); }
            &:hover { background-color: #e0e0e0;border: 1px solid #aaa; }
        }
        &:hover{
            border: 1px solid #aaaaaa;
            background-color: #e0e0e0;
            color: black;
        }
    }

    .rg-caret-down {
        display: inline-block;
        width: 0;
        height: 0;
        margin-left: 5px;
        border-top: 4px solid;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        /*float: right;*/
        /*margin-top: 3px;*/
        vertical-align: middle;
        content: "";
        /*        position: absolute;
                top: 7px;
                right: 10px;*/
    }

    div.rg-header {
        min-width: 400px;
        background-color: $darkBg;
        & > h3 {
            padding: 6px 80px 10px 10px;
            margin: 0;
            text-align: left;
            color: #24292e;
            font-size: 16px;
            white-space: nowrap;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
            .rg-header-selected{
                white-space: nowrap;
                text-overflow: ellipsis;
                -o-text-overflow: ellipsis;
                overflow: hidden;
                font-size: 14px;
                max-width: 310px;
                display: inline-block;
            }
        }
        button{
            position: absolute;
            -webkit-appearance: none;
            padding: 0;
            cursor: pointer;
            background: 0 0;
            border: 0;
            outline: none;
            line-height: 100%;
            color: #999999;
            top: 3px;
            font-size: 20px;
            &.rg-close-button { right: 10px;font-size: 26px;top:0;font-weight: 300; }
            &.rg-removeall-button { right: 32px; }
            &.rg-done-button { /*right: 54px;*/right: 8px;top: 4px;i{font-size: 18px;} }
            &:hover { color: black; }
        }
    }
    div.rg-search {
        padding: 2px 10px 10px;
        background-color: $darkBg;
    }

    .rg-input {
        display: block;
        background-color: white;
        margin: 0 !important;
        width: 100%;

        font-size: 14px;
        line-height: 20px;
        min-height: 20px;
        padding: 4px 6px;
        vertical-align: middle;
        box-sizing: border-box;

        outline: none !important;
        height: 30px;

        border-radius: 2px;
        border: 1px solid #dddddd;
        -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
        -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
        box-shadow: inset 0 1px 1px rgba(0,0,0,.075);

        transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
        &:focus { border: 1px solid #bbbbbb;box-shadow: 0 0 0 3px rgba(150,150,150, 0.2); }
    }

    /* group type */
    div.rg-level-tabs {
        padding: 0 10px;border-bottom: 1px solid #E6E7E7;
        background-color: $darkBg;
        ul {
            position: relative;
            bottom: -1px;
            padding: 0;
            margin: 0;
            text-align: left;
            li {
                display: inline-block;
                a {
                    display: inline-block;
                    padding: 7px 10px 3px;
                    font-size: 14px;
                    color: #6a737d;
                    text-decoration: none;
                    cursor: pointer;
                    line-height: 100%;
                    background: transparent;
                    border: 1px solid transparent;
                    border-radius: 3px 3px 0 0;
                    font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
                    &.active {
                        color: #24292e;
                        background-color: #fff;
                        border-color: #dfe2e5;
                        border-bottom-color: #fff;
                        /*font-weight: bold;*/
                    }
                }
            }
        }
    }

    div.rg-results-container{
        background-color: white;
        list-style: none;
        margin: 0;
        padding: 0;
        position: relative;
        width: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        clear: both;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        ul.rg-results {
            background-color: white;
            list-style: none;
            margin: 0;
            padding: 5px;
            /*height: 300px;*/
            width: 400px;
            li.rg-item {
                display: inline-block;
                /*border: 1px solid white;*/
                border-radius: 2px;
                margin-right: 5px;
                color: #777;
                &:hover{
                    /*border: 1px solid #DDDDDD;*/
                    /*box-shadow: 0 1px 8px rgba(0,0,0,0.2);*/
                    /*-moz-box-shadow: 0 1px 8px rgba(0,0,0,0.2);*/
                    /*-webkit-box-shadow: 0 1px 8px rgba(0,0,0,0.2);*/
                    color: black;
                    background-color: #F5F5F5;
                }
                &.active {
                    /*border: 1px solid #666666;background-color: #DDDDDD;*/
                    background-color: #55A2E6;color: white;
                }
            }
            & > li {
                /*height: auto;
                line-height: 1;*/
                margin: 0;
                overflow: hidden;
                padding: 3px 10px;
                position: relative;
                text-align: left;
                white-space: nowrap;
                font-size: 14px;
                color: black;
                cursor : pointer;
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
                &.rg-message-box {
                    height: 30px;
                    line-height: 30px;
                    text-align: center;
                    box-sizing: content-box;
                    font-size: 14px;
                    cursor: default;
                    i { font-size: 18px; }
                }
            }
        }
    }
    div.rg-selected-container {
        /*padding: 5px 16px 7px;*/
        border-top: 1px solid #E6E7E7;
        background-color: white;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        display: inline-block;
        width: 400px;
        position: relative;
        div.rg-selected-content{
            /*margin-right: 30px;*/
            display: inline-block;
            width: 350px;
        }
        div.rg-done {
            height: 100%;
            width: 50px;
            display: inline-block;
            text-align: center;
            position: absolute;
            top: 0;
            bottom: 0;
            right: 0;
            i{
                line-height: 1;
                font-size: 20px;
                top: 50%;
                position: absolute;
                margin-top: -10px;
            }
        }
    }
    div.rg-column-container{
        clear: both;
        ul{
            border-right: 1px solid #DDDDDD;
            &:last-child { border-right: 0; }
        }
    }


    /* icons */
    @font-face {font-family: "rg-iconfont";
        src: url(''); /* IE9*/
        src: url('') format('embedded-opentype'), /* IE6-IE8 */
        url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAXYAAsAAAAACMgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY8dkk9Y21hcAAAAYAAAABxAAAByIIAhoJnbHlmAAAB9AAAAcUAAAJA3vCOfmhlYWQAAAO8AAAALwAAADYTSzUfaGhlYQAAA+w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CwHv4/ltvjJwszCAwA3RHxMQ9P/9LAzMzkAuBwMTSBQANXsKvwB4nGNgZGBgbvjfwBDDAmQxMLAwMIBpJMAGAEclAnAAAHicY2FgYGBBx4wMDAABawAaAAAAAAAAAAAuAKwA1AD+ASAAAHicY2BkYGBgYwhjYGUAASYg5gJCBob/YD4DABHFAXgAeJxlj01OwzAQhV/6B6QSqqhgh+QFYgEo/RGrblhUavdddN+mTpsqiSPHrdQDcB6OwAk4AtyAO/BIJ5s2lsffvHljTwDc4Acejt8t95E9XDI7cg0XuBeuU38QbpBfhJto41W4Rf1N2MczpsJtdGF5g9e4YvaEd2EPHXwI13CNT+E69S/hBvlbuIk7/Aq30PHqwj7mXle4jUcv9sdWL5xeqeVBxaHJIpM5v4KZXu+Sha3S6pxrW8QmU4OgX0lTnWlb3VPs10PnIhVZk6oJqzpJjMqt2erQBRvn8lGvF4kehCblWGP+tsYCjnEFhSUOjDFCGGSIyujoO1Vm9K+xQ8Jee1Y9zed0WxTU/3OFAQL0z1xTurLSeTpPgT1fG1J1dCtuy56UNJFezUkSskJe1rZUQuoBNmVXjhF6XNGJPyhnSP8ACVpuyAAAAHicY2BigAAuBuyAjZGJkZmRhZGVkY2RnYGtojQxryqVvTgjMS85o5QlJb88jzUoMz2jhLUkMze1mIEBANuHC6w=') format('woff'),
        url('') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
        url('') format('svg'); /* iOS 4.1- */
    }

    .rg-iconfont {
        font-family:"rg-iconfont" !important;
        font-size:14px;
        font-style:normal;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    .icon-done:before { content: "\e72e"; }
    .icon-remove:before { content: "\e74b"; }
    .icon-down:before { content: "\e610"; }
    .icon-right:before { content: "\e612"; }
    .icon-clear:before { content: "\e600"; }
</style>